{extend name="base" /}

{block name="title"} 插件市场 {/block}

{block name="body"}

<div class="col-lg-12">
    <section class="panel">
        <header class="panel-heading">插件市场</header>
        <div class="panel-body">
            
            
            {volist name="list" id="vo" key="k"}
            <div class="col-xs-4 {$k%2==0?'bg-primary':'bg-warning'} pd-sm text-center">
                <a href="javascript:;">
                    {$vo.type} - {$vo.version}
                    <!-- <span>{$vo.author} - {$vo.email}</span> -->
                    <span class="fa fa-heart show mg-b-xs mg-b-xs"></span> 
                    {$vo.name}
                </a>
                <div>
                    {if in_array($vo['code'],$install) }
                        <strong class="pull-left" >
                            <button class="btn btn-sm btn-danger" type="button" onclick="uninstall('{$vo.path}')"> 卸载 </button>
                        </strong>
                    {else /}
                        <span class="pull-left">
                            <button class="btn btn-sm btn-success" type="button" onclick="install('{$vo.path}')"> 安装 </button>
                        </span>
                    {/if}

                    <strong class="pull-left" >
                        <button class="btn btn-sm btn-primary" type="button" onclick="conf('{$vo.path}')"> 配置 </button>
                    </strong>
                </div>
            </div>
            {/volist}
            
            
        </div>
    </section>
</div>




{/block}


<!-- js -->
{block name="js"}
<script>
// 获取配置文件
function conf( urls ){
    $.get("{:url('conf')}",{"path":urls} ,function(data) {

		if( data.error >0 ){
			toastr.error(data.msg);
		}else{
			layer.open({
				type: 1,
			　　title: "编辑配置",
			　　shadeClose: true,
			　　shade: 0.4,
				anim: 5,
			　　content: data
			});
		}

    });

}

// 安装
function install(path){
    $.post("{:url('install')}",{"path":path} ,function(data) {

        if( data.error == 0 ){
			toastr.success(data.msg);
            setTimeout(function(){
                window.location.reload();
            },1000); 
        }else{
			toastr.error(data.msg);
		}
    });
}

// 卸载
function uninstall(path){

	//询问框
	layer.confirm('你确定要卸载?', function(){
		$.post("{:url('uninstall')}",{"path":path} ,function(data) {

			if( data.error == 0 ){
				toastr.success(data.msg);
				setTimeout(function(){
					window.location.reload();
				},1000);    
			}else{
				toastr.error(data.msg);
			}
		});
	});

}
</script>
{/block}